package com.iwhalecloud.citybrain.flow.platform.manager.application.service.impl;

import com.fasterxml.jackson.databind.JsonNode;
import com.iwhalecloud.citybrain.flow.platform.manager.application.common.context.FlowElementProcessContext;
import com.iwhalecloud.citybrain.flow.platform.manager.application.service.CustomPropertiesProcessor;
import com.iwhalecloud.citybrain.flow.platform.manager.common.ConstanceVariable;
import org.springframework.stereotype.Service;

/**
 * @author: liyang
 * @date: 2021/10/9 17:04
 */
@Service
public class SaveNodeFormFieldLimitProcessor extends SaveFormFieldLimitAbstractProcessor implements CustomPropertiesProcessor {

    @Override
    public boolean support(JsonNode elementNode) {
        JsonNode properties = elementNode.get("properties");
        if (nonNull(properties)) {
            return nonNull(properties.get(ConstanceVariable.FORM_FIELDS));
        }
        return false;
    }

    @Override
    public void process(FlowElementProcessContext context) {
        JsonNode modelJson = context.getElementNode();
        saveFormField(modelJson,context.getDeployId(),"1");
    }
}
